<?php
/**
*	作者：信呼开发团队(雨中磐石)
*	官网：http://www.rockoa.com
*	软件：REIM即时通讯平台
*	回调使用
*/
class hdiaoClassModel extends Model
{
	/**
	*	$cid 单位id，
	*	$msgtype 消息类型，$msgevent 事假
	*/
	public function send($cid, $msgtype, $msgevent, $data=array())
	{
		$xinfo 		= m('company')->getXinxi($cid);
		$hdiaourl 	= $xinfo['hdiaourl'];
		if(isempt($hdiaourl))return;
		$hdiaokey 	= $xinfo['hdiaokey'];
		if(isempt($hdiaokey))$hdiaokey = $xinfo['secret'];
		if(isempt($hdiaokey))$hdiaokey = $xinfo['num'];
		$key 		= md5($hdiaokey);
		
		$sdata['msgtype']  = $msgtype;
		$sdata['msgevent'] = $msgevent;
		foreach($data as $k=>$v)$sdata[$k]=$v;
		
		$body 	= $this->rock->jm->strlook(json_encode($sdata, JSON_UNESCAPED_UNICODE), $key);
		$urla 	= $this->rock->jm->base64encode($hdiaourl);

		return m('reim')->push('cli,hdiaosend', array(
			'urla'	=> $urla,
			'body'	=> $body,
		));
	}
}